/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bash.carrep.ui.util;

import com.vaadin.data.Item;
import com.vaadin.data.validator.DoubleValidator;
import com.vaadin.ui.Component;
import com.vaadin.ui.Field;
import com.vaadin.ui.TextField;

/**
 *
 * @author p.bashizi
 */
public class CategPMFieldFactory extends PojoFieldFactory {

    public CategPMFieldFactory() {
    }

    @Override
    public Field createField(Item item, Object propertyId, Component uiContext) {

        Field f = super.createField(item, propertyId, uiContext);


        if ("description".equals(propertyId)) {

            TextField tf = (TextField) f;
            tf.setNullRepresentation("");
            tf.setRequired(true);
            tf.setCaption("Description");
            tf.setRequiredError("Veuillez donner la description");
            tf.setWidth("15em");
            

        } else if ("tauxExoneration".equals(propertyId)) {

            TextField tf = (TextField) f;
            tf.setNullRepresentation("");
            tf.setRequired(true);
            tf.setWidth("15em");
            tf.setRequiredError("Veuillez donner le taux");
            tf.addValidator(new DoubleValidator("Le taux doit être un nombre réel positif"));
          
        }

        return f;
    }
}
